package com.tencent.cloud.tuikit.tuicall_engine.utils;

import com.tencent.qcloud.tuikit.tuicallengine.TUICallDefine;

import java.util.Map;

public class ObjectUtils {

    public static TUICallDefine.CallParams getTUICallParamsByMap(Map map) {
        if (map == null || map.size() <= 0) {
            return null;
        }
        TUICallDefine.CallParams params = new TUICallDefine.CallParams();
        if (map.get("offlinePushInfo") != null) {
            params.offlinePushInfo = getTUIOfflinePushInfoByMap((Map) map.get("offlinePushInfo"));
        }
        return params;
    }

    public static TUICallDefine.OfflinePushInfo getTUIOfflinePushInfoByMap(Map map) {
        if (map == null || map.size() <= 0) {
            return null;
        }
        TUICallDefine.OfflinePushInfo offlinePushInfo = new TUICallDefine.OfflinePushInfo();
        if (map.get("title") != null) {
            offlinePushInfo.setTitle((String) map.get("title"));
        }
        if (map.get("desc") != null) {
            offlinePushInfo.setDesc((String) map.get("desc"));
        }
        if (map.get("ignoreIOSBadge") != null) {
            offlinePushInfo.setIgnoreIOSBadge((boolean) map.get("ignoreIOSBadge"));
        }
        if (map.get("iOSSound") != null) {
            offlinePushInfo.setIOSSound((String) map.get("iOSSound"));
        }
        if (map.get("androidSound") != null) {
            offlinePushInfo.setAndroidSound((String) map.get("androidSound"));
        }
        if (map.get("androidOPPOChannelID") != null) {
            offlinePushInfo.setAndroidOPPOChannelID((String) map.get("androidOPPOChannelID"));
        }
        if (map.get("androidVIVOClassification") != null) {
            offlinePushInfo.setAndroidVIVOClassification((int) map.get("androidVIVOClassification"));
        }
        return offlinePushInfo;
    }

}
